package com.huawei.hianalytics.ab.bc.de;

import android.text.TextUtils;
import com.huawei.hianalytics.ab.ab.cd;
import com.huawei.hianalytics.ab.bc.cd.bc.de;
import com.huawei.hianalytics.ab.bc.ef.ab;
import com.huawei.hms.framework.network.restclient.hwhttp.route.IPRoute;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class bc {
    private List<de> ab;
    private String bc;
    private String cd;
    private String de;

    public bc(List<de> list, String str, String str2, String str3) {
        this.ab = list;
        this.bc = str;
        this.cd = str2;
        this.de = str3;
    }

    private void ab(List<de> list, String str, String str2) {
        if (!list.isEmpty()) {
            int size = (list.size() / IPRoute.INTERVAL) + 1;
            for (int i = 0; i < size; i++) {
                int i2 = i * IPRoute.INTERVAL;
                List<de> subList = list.subList(i2, Math.min(list.size(), i2 + IPRoute.INTERVAL));
                String replace = UUID.randomUUID().toString().replace("-", "");
                long currentTimeMillis = System.currentTimeMillis();
                long gh = ((long) cd.gh(str2, str)) * HwAccountConstants.CHECK_SITE_COUNTRY_DURATION;
                List arrayList = new ArrayList();
                for (de deVar : subList) {
                    if (!com.huawei.hianalytics.ab.bc.kl.bc.ab(deVar.bc(), currentTimeMillis, gh)) {
                        arrayList.add(deVar);
                    }
                }
                if (arrayList.size() > 0) {
                    new cd(str2, str, this.de, arrayList, replace).ab();
                } else {
                    ab.cd("DataOrganizeHandler", "No data to report handler");
                }
            }
        }
    }

    public void ab() {
        if ("_default_config_tag".equals(this.cd)) {
            List arrayList = new ArrayList();
            List arrayList2 = new ArrayList();
            List arrayList3 = new ArrayList();
            List arrayList4 = new ArrayList();
            for (de deVar : this.ab) {
                CharSequence ab = deVar.ab();
                if (TextUtils.isEmpty(ab) || "oper".equals(ab)) {
                    arrayList4.add(deVar);
                } else if ("maint".equals(ab)) {
                    arrayList.add(deVar);
                } else if ("preins".equals(ab)) {
                    arrayList2.add(deVar);
                } else if ("diffprivacy".equals(ab)) {
                    arrayList3.add(deVar);
                }
            }
            ab(arrayList4, "oper", "_default_config_tag");
            ab(arrayList, "maint", "_default_config_tag");
            ab(arrayList2, "preins", "_default_config_tag");
            ab(arrayList3, "diffprivacy", "_default_config_tag");
            return;
        }
        ab(this.ab, this.cd, this.bc);
    }
}
